<?php

namespace core\lib;

use medoo;
use PDOException;

class model {
    static $connects = [];

    public static function use ($database = null) {
        if (!array_key_exists($database, self::$connects)) {
            $options = config::all('database');
            try {
                $medoo = new medoo($options);
            } catch (PDOException $e) {
                echo $e->getMessage();
            }
            self::$connects[$database] = $medoo;
            return $medoo;
        } else {
            return self::$connects[$database];
        }
    }

}